package com.lqm.web.controller.home;

import com.lqm.entity.home.ProjectType;
import com.lqm.service.home.ProjectTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: CrowdFunding
 * @description
 * @author: lqm
 * @create: 2018-12-17 16:18
 */
@RestController

public class ProjectTypeController {
    @Autowired
    ProjectTypeService projectTypeService;

    /**
     * 返回正常使用的项目类型
     *
     * @return
     */
    @RequestMapping("/home/getAllProjectType")
    public List<ProjectType> getAllProjectType() {
        return projectTypeService.getAllProjectTypeByStatus(1);
    }

    /**
     * 返回正常使用的项目类型
     *
     * @return
     */
    @RequestMapping("/admin/getAllProjectType")
    public Map<String, Object> getAllProjectTypeAdmin() {
        Map<String, Object> map = new HashMap<>(0);
        map.put("msg","");
        map.put("code",0);
        map.put("data",projectTypeService.getAllProjectType());
//        map.put("count",);
        return map;
    }

    @RequestMapping("/admin/setProjectTypeStatus")
    public Map<String, Object> setProjectTypeStatus(ProjectType projectType,int status) {
        Map<String, Object> map = new HashMap<>(0);
        projectTypeService.setProjectTypeStatus(projectType,status);

        map.put("msg","成功");
        map.put("code",0);
//        map.put("count",);
        return map;
    }

}
